package kang.zhoujin.util;

import java.awt.AWTException;
import java.awt.Color;
import java.awt.Robot;

public class PixelColorUtil {
	private Robot robot = null;
	public PixelColorUtil() throws AWTException{
		robot = new Robot();
	}

	public Color getPixelColor(int x, int y){
		return robot.getPixelColor(x, y);
	}

	public String getPixelColorStr(int x, int y){
		Color color = robot.getPixelColor(x, y);
		int red = color.getRed();
		int green = color.getGreen();
		int blue = color.getBlue();
		String colorStr = Integer.toHexString(blue).toUpperCase() + 
						  Integer.toHexString(green).toUpperCase() +
						  Integer.toHexString(red).toUpperCase();
		
		return colorStr;
	}

	public int getPixelRed(int x, int y){
		Color color = robot.getPixelColor(x, y);
		return color.getRed();
	}
	
	public int getPixelGreen(int x, int y){
		Color color = robot.getPixelColor(x, y);
		return color.getGreen();
	}
	
	public int getPixelBlue(int x, int y){
		Color color = robot.getPixelColor(x, y);
		return color.getBlue();
	}
}
